home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / pc / RGASM.RAR / ASMCODE.EXE / CHAPT1-5 / DETSTEP.ASM < prev    next >
Encoding:
Assembly Source File  |  1993-05-10  |  1.8 KB  |  41 lines

  1. ;
  2. ;       Program DetStep ( Chapter 2 )
  3. ;
  4. page 55,132
  5. .model  small
  6. .stack
  7. .data
  8. TitMsg  db      'The program for demonstration the Trap Flag''s work.',0Dh,0Ah
  9.     db      0Dh,0Ah,'$'
  10. NotSet  db      'Cannot set the Trap Flag - the program works under debugger.'
  11.     db      0Dh,0Ah,'$'
  12. IsSet   db      'The trap flag is set successfully. No debugger active found.'
  13.     db      0Dh,0Ah,'$'
  14. .code
  15. .startup
  16.     lea     dx,TitMsg               ; address of initial message 
  17.     mov     ah,09                   ; function 09 - output text string
  18.     int     21h                     ; DOS service call
  19.     pushf                           ; push original flags
  20.     pop     ax                      ; copy original flag into AX
  21.     or      ax,0100h                ; set bit 8 - Trap Flag
  22.     push    ax                      ; push flags value to be set
  23.     popf                            ; pop flags with TF set
  24.     pushf                           ; push new flags value
  25.     pop     ax                      ; copy new flags into AX
  26.     and     ax,0100h                ; separate bit 8 - highlight TF
  27.     lea     dx,IsSet                ; address of message "TF is set" 
  28.     cmp     ax,0                    ; is bit 8 clear?
  29.     jne     OutMsg                  ; if not, output message
  30.     lea     dx,NotSet               ; address of message "cannot set TF"
  31. OutMsg: mov     ah,09                   ; function 09 - output text string
  32.     int     21h                     ; DOS service call
  33.     pushf                           ; push original flags
  34.     pop     ax                      ; copy original flag into AX
  35.     and     ax,not 0100h            ; clear bit 8 - Trap Flag
  36.     push    ax                      ; push flags value to be set
  37.     popf                            ; pop flags with TF clear       
  38.     mov     ax,4C00h                ; function 4Ch - terminate process
  39.     int     21h                     ; DOS service call
  40.     end
  41.